﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using Capstone_project.DatabaseAccessLayer;
using Capstone_project.BussnessLogicLayer;

namespace Capstone_project
{
    public partial class frmAddMemberIntoTeam : Form
    {
        public frmAddMemberIntoTeam()
        {
            InitializeComponent();
        }
        DataSet ds1 = Common.ds;
        DataSet ds2 = Common.ds;
        OleDbConnection con = Common.con;
        OleDbCommand com1;
        OleDbDataAdapter adap1;
        public const string ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Documents\capston\Capstone 2\CapstoneProjectCLGGroup\Capstone project\database.accdb";
        public DataTable GetUser() {

            OleDbConnection con = new OleDbConnection(ConnectionString);
            con.Open();
            OleDbCommand cmd = new OleDbCommand("SELECT USER_NAME FROM [USER]", con);
            OleDbDataAdapter ad = new OleDbDataAdapter(cmd);
            DataTable dtbl = new DataTable();
            ad.Fill(dtbl);
            con.Close();
            return dtbl;
        
        }
        private void frmAddMemberIntoTeam_Load(object sender, EventArgs e)
        {

            listBox1.DataSource = GetUser();
            listBox1.DisplayMember = "USER_NAME"; // Listbox sẽ hiện thị tên sản phẩm
            //listBox1.ValueMember = "USER_NAME";//Lưu mã sản phẩm để xử lý sau (nếu có)
           
           

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex < 0) return;
            listBox2.Items.Add(listBox1.SelectedItem);
            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
        }

       
           

        private void button2_Click(object sender, EventArgs e)
        {
         if (listBox2.SelectedIndex < 0) return;
            listBox1.Items.Add(listBox2.SelectedItem);
            listBox2.Items.RemoveAt(listBox2.SelectedIndex);
        }
        
       

      

     
    }
}
